#encoding utf-8

#模拟登陆正方

import urllib.request
from urllib import request,parse

print('Login to SCAUZhengFang...')
username=input('学号：')
password=input('密码：')
login_data=parse.urlencode([
    ('username',username),
    ('password',password),
])

req=request.Request('http://202.116.160.170/default2.aspx')
req.add_header('Origin','http://202.116.160.170/default2.aspx')
req.add_header('User-Agent','Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36')
req.add_header('Reference','http://202.116.160.170/')

with request.urlopen(req,data=login_data.encode('GBK','ignore')) as f:
    print('Status:',f.status,f.reason)
    print('Data:',f.read().decode('GBK'))
